package com.xiaohe.controller;

import com.xiaohe.service.ContentService;
import com.xiaohe.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.io.IOException;
import java.util.List;
import java.util.Map;

/**
 * 功能描述
 *
 * @author 和振斌
 * @date 2020/9/25
 * @return
 */
@RestController
@CrossOrigin
public class ContentController {

    @Autowired
    private ContentService contentService;

    @GetMapping("/parse/{keywords}")
    public Boolean paras(@PathVariable String keywords) throws IOException {
       return contentService.parseContent(keywords);
    }

    @GetMapping("/search/{keywords}/{pageNo}/{pageSize}")
    public List<Map<String,Object>> search(
                    @PathVariable("keywords") String keywords,
                    @PathVariable("pageNo") int pageNo,
                    @PathVariable("pageSize") int pageSize) throws IOException {

        List<Map<String, Object>> maps = contentService.searchPageByHighLight(keywords, pageNo, pageSize);
        return maps;
    }


}
